//
// Created by Administrator on 2023/8/28.
// 十进制转N进制(2<=N<=36) 转为36进制最大值是Z
// https://www.luogu.com.cn/problem/B3619
// 通过


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int num =355, n = 36;
    cin>>num>>n;
    vector<char> ans;
    int t = num;
    while(t)
    {
//        cout << t%n<<endl;
        if(t%n<10)
            ans.push_back(t%n+'0');
        else
            ans.push_back(t%n+'A'-10);
        t/=n;
    }
    for (int i = ans.size()-1; i >=0 ; --i)
    {
        cout<<ans[i];
    }
    return 0;
}